package com.amat0urheu.service.cloudService.impl;
/*
 *@Auther:amaT0ur
 *@create:2023-11-15
 */

import com.amat0urheu.dao.IpPortMapper;
import com.amat0urheu.pojo.CloudPojo.IpPort;
import com.amat0urheu.pojo.ReturnRes;
import com.amat0urheu.service.cloudService.IpPortService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
@Service
public class IpPortServiceImpl implements IpPortService {
    @Autowired
    IpPortMapper ipPortMapper;
    @Override
    public ReturnRes getIpports(Integer pageSize, Integer pageNum) {
        PageHelper.startPage(pageNum, pageSize);
        List<IpPort> ipPorts = ipPortMapper.getIpPorts();
        if (ipPorts != null) {
            return new ReturnRes(true, new PageInfo<>(ipPorts), "查询成功");
        }

        return new ReturnRes(false, "查询失败");
    }

    @Override
    public ReturnRes saveIpport(IpPort ipPort) {
        int count=ipPortMapper.saveIpport(ipPort);
        if(count>0){
            return new ReturnRes(true, "增加成功");
        }
           return new ReturnRes(false, "操作失败");
    }

    @Override
    public ReturnRes removeIpport(Integer id) {


        int count=ipPortMapper.removeIpport(id);
        if(count>0){
            return new ReturnRes(true, "删除成功");
        }
        return new ReturnRes(false, "操作失败");
    }
}
